package com.itheima.controller.sms;

import com.itheima.core.PageInfo;
import com.itheima.core.R;
import com.itheima.pojo.sms.SmsCouponHistory;
import com.itheima.service.sms.SmsCouponHistoryService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/couponHistory")
public class SmsCouponHistoryController {

    @DubboReference
    private SmsCouponHistoryService couponHistoryService;

    /**
     *根据优惠券id，使用状态，订单编号分页获取领取记录
     * @param couponId
     * @param orderSn
     * @param pageNum
     * @param pageSize
     * @param useStatus
     * @return
     */
    @GetMapping("/list")
    private R historyRecord(@RequestParam(required = false) Integer couponId,
                            @RequestParam(required = false) String orderSn,
                            @RequestParam(required = false) Integer pageNum,
                            @RequestParam(required = false) Integer pageSize,
                            @RequestParam(required = false) Integer useStatus){

        PageInfo pageInfo = couponHistoryService.historyRecord(couponId, orderSn, pageNum, pageSize, useStatus);

        return R.success(pageInfo);
    }
}
